package com.group3.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.group3.Feign.ProductServiceFeign;
import com.group3.dao.OrderDao;
import com.group3.model.Order;
import com.group3.service.OrderSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class OrderSeviceImpl implements OrderSevice {
    @Autowired

    private OrderDao orderDao;


    @Autowired
    ProductServiceFeign productServiceFeign ;

    @Override
    public List<Order> getOrderListbyUid(Integer uid) {
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", uid);
        List<Order> orderList = orderDao.selectList(queryWrapper);
        return orderList;
    }

    @Override
    public Order getOrderByOid(Integer oid) {
        Order order = orderDao.selectById(oid);
        if(order!=null){
            return order;
        }
        return null;
    }

    @Override
    public boolean addOrder(Order order) {
        if(orderDao.insert(order)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean updateOrder(Order order) {
        if(orderDao.updateById(order)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteOrder(Integer oid) {
        if(orderDao.deleteById(oid)>0){
            return true;
        }
        return false;
    }


}
